package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.annotation.LoginAnnotation;
import cn.wolfcode.wolf2w.annotation.UserInfoResolver;
import cn.wolfcode.wolf2w.domain.Destination;
import cn.wolfcode.wolf2w.domain.Spot;
import cn.wolfcode.wolf2w.domain.UserInfo;
import cn.wolfcode.wolf2w.query.SpotQuery;
import cn.wolfcode.wolf2w.service.IDestinationService;
import cn.wolfcode.wolf2w.service.ISpotService;
import cn.wolfcode.wolf2w.util.JsonResult;
import cn.wolfcode.wolf2w.util.UMEditorUploader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;


@RestController
@RequestMapping("spots")
public class SpotController {
    @Autowired
    private ISpotService spotService;
    @Autowired
    private IDestinationService destinationService;

     @GetMapping("query")
    public Object list(SpotQuery qo){
        Page<Spot> list = spotService.queryPageList(qo);
        return JsonResult.success(list);
    }

    /**
     * 游记
     * @param id
     * @return
     */
    @GetMapping("detail")
    public Object detail(String id){
        Spot spot = spotService.get(id);
        return JsonResult.success(spot);
    }


    @GetMapping("input")
    public Object input(String id){
        List<Destination> dests = destinationService.list();
      //  Spot spot = spotService.get(id);
        HashMap<Object, Object> map = new HashMap<>();
        map.put("dests",dests);
     //   map.put("tv",spot);
        return JsonResult.success(map);
    }


}